home *** CD-ROM | disk | FTP | other *** search
- *****************************************************************************
- * IFF ILBM-2-BITMAP BITPLANES Used Registers Preserved
- * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
- * Converts an IFF Picture (Packed or Non-Packed) to raw-bitmap non-
- * interleaved bitplanes. Colours are also Converted and saved after bitplanes
- * This version is only for standard IFF pictures with 64-Colours or less!
- *
- * INPUTS: a0=Source IFF ILBM Picture a1=Destination BITPLANES
- * a2=Palette Buffer (IF a2=0 , no palette colors extracted!)
- * OUTPUTS: None.
- *****************************************************************************
-
- IFFDecrunch movem.l d0-d7/a0-a6,-(sp)
- lea PalettePt(pc),a6
- move.l a2,(a6) ;save palette destination adr
- bsr.s IFF2BM ;decrunch picture
- movem.l (sp)+,d0-d7/a0-a6
-
- move.l widby(pc),d0 ;screen width (in bytes)
- move.w height(pc),d1 ;screen height (in pixels)
- move.l PlaneSize(pc),d2 ;size of one bitplane
- moveq #0,d3
- move.b bplanes(pc),d3 ;number of bitplanes
- rts
-
- IFF2BM move.l a0,a3
- getiff moveq #1,d5
- cmp.l #'FORM',(a0)+ ; check ID, iff piccy ?
- bne.w notiff
- cmp.l #'ILBM',4(a0) ; interleaved bitmap ?
- bne.w notiff
- move.l #'BMHD',d0
- addq.l #8,a0
-
- iscmap cmp.l (a0),d0
- beq.s dimen
- tst.l (a0)+
- add.l (a0)+,a0
- bra.s iscmap
-
- dimen addq.l #8,a0
- lea width(pc),a4
- move.l (a0),(a4)
- move.b 8(a0),bplanes-width(a4)
- move.l a0,a5
- move.l #'BODY',d0
- move.l a3,a0
- lea 12(a0),a0
-
- isbody cmp.l (a0),d0
- beq.s bitmap
- tst.l (a0)+
- add.l (a0)+,a0
- bra.s isbody
-
- bitmap addq.l #8,a0
- move.l a0,datast-width(a4)
- moveq #0,d0
- move.w (a4),d0 ;get width
- cmp.w #16,d0
- bhi.s contin
-
- moveq #2,d0
- move.l d0,widby-width(a4)
- bra.s mqwe
-
- contin lsr #4,d0
- swap d0
- tst.w d0
- beq.s cont
-
- swap d0
- add.w d5,d0
- swap d0
- cont swap d0
- add.w d0,d0
- and.l #$FFFF,d0
- move.l d0,widby-width(a4)
-
- mqwe mulu height(pc),d0
- move.l d0,planeSize-width(a4)
- mulu planes(pc),d0
- move.l d0,planetot-width(a4)
-
- move.l planetot(pc),d1
- move.l widby(pc),d2
- move.l datast(pc),a0
-
- move.l planetot(pc),d1
- tst.b 10(a5) ;is data ByteRun compressed ?
- bne.s compressed
-
- planego moveq #0,d3
- loopy add.w d5,d3
- move.l widby(pc),d2
- sub.w d5,d2
-
- looptranz move.b (a0)+,(a1)+
- sub.l d5,d1
- dbra d2,looptranz
-
- tst.l d1
- beq.w getcmap
-
- cmp.w planes(pc),d3
- beq.s plane1
-
- add.l planeSize(pc),a1
- sub.l widby(pc),a1
- bra.s loopy
-
- plane1 move.l planetot(pc),d4
- sub.l planeSize(pc),d4
- sub.l d4,a1
- bra.s planego
-
- compressed move.l -4(a0),d1
- planeeq1 moveq #0,d7
- nextplane add.b d5,d7
- moveq #0,d2
- loopgb move.b (a0),d0
- cmp.b #128,d0
- beq.s noop
-
- bclr #7,d0
- beq.s uplit
- bne.s uprepl
-
- ret cmp.b store2(pc),d2
- bne.s loopgb
- here tst.l d1
- beq.s getcmap
-
- cmp.b bplanes(pc),d7
- beq.s plane1er
-
- add.l planeSize(pc),a1
- sub.l widby(pc),a1
- bra.s nextplane
-
- plane1er sub.l planetot(pc),a1
- add.l planeSize(pc),a1
- bra.s planeeq1
-
- noop sub.l d5,d1
- add.l d5,a0
- bra.s ret
-
- uplit add.b d0,d2
- add.b d5,d2
- add.l d5,a0
- subq.l #2,d1
- ext.w d0
- ext.l d0
- sub.l d0,d1
-
- looptrans move.b (a0)+,(a1)+
- dbra d0,looptrans
- bra.s ret
-
- uprepl move.b #128,d3
- sub.b d0,d3
- add.b d3,d2
- add.b d5,d2
- move.b 1(a0),d0
- addq.w #2,a0
- subq.l #2,d1
- ext.w d3
- ext.l d3
-
- looprepl move.b d0,(a1)+
- dbra d3,looprepl
- bra.s ret
-
- getcmap: move.l a3,a0
- lea 40(a0),a0
- move.l (a0)+,d0
- lea 4(a0),a1
- move.l PalettePt(pc),a2 ; dest for save palette
- move.l a2,d0
- beq.s doneok
- moveq.l #32-1,d0
- getc: moveq #0,d1
- move.b (a1)+,d1
- rol.w #4,d1
- move.b (a1)+,d1
- move.b (a1)+,d2
- lsr.b #4,d2
- or.b d2,d1
- move.w d1,(a2)+
- dbra d0,getc
- doneok rts
-
- notiff moveq #-1,d0
- rts
-
- PalettePt dc.l 0
- planetot dc.l 0
- planeSize dc.l 0
- datast dc.l 0
- width dc.w 0
- height dc.w 0
- widby dc.w 0 ;\
- widbylow dc.b 0 ; \
- store2 dc.b 0 ; \_attached do not move!
- planes dc.b 0
- bplanes dc.b 0
- swidth dc.w 0
- NumCols dc.w 0
-
-
-